package com.grapecc.springcloud.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 卖糖的兜兜
 * @version 1.0.0
 * @ClassName GateWayConfig.java
 * @Description TODO
 * @createTime 2022年03月06日 21:21:00
 */
@Configuration
public class GateWayConfig {

    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder routeLocatorBuilder){

        RouteLocatorBuilder.Builder routes = routeLocatorBuilder.routes();
//        localhost:9527/guonei -> http://www.baidu.com/guonei
        routes.route("payment_routh3", r-> r.path("/guonei")
                .uri("http://www.baidu.com")).build();
        return routes.build();
    }

    @Bean
    public RouteLocator customRouteLocator2(RouteLocatorBuilder routeLocatorBuilder){

        RouteLocatorBuilder.Builder routes = routeLocatorBuilder.routes();
//        localhost:9527/guoji -> http://www.baidu.com/guonei
        routes.route("payment_routh4", r-> r.path("/guoji")
                .uri("http://news.baidu.com/guoji")).build();
        return routes.build();
    }
}
